package com.xn.app.muying.adpter;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.xn.app.muying.R;
import com.xn.app.muying.activity.KePuActivity;

import java.util.ArrayList;

/**
 * Created by Administrator on 2016/10/10.
 */
public class HomeAdpter extends BaseAdapter{
    private Context context;
    private LayoutInflater inflater;
    private ArrayList<String> data = new ArrayList();


    public HomeAdpter(Context context,ArrayList<String> data){
     this.context = context;
        this.data = data;
     inflater = LayoutInflater.from(context);
    }
    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int i) {
        return data.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int position, View view, ViewGroup viewGroup) {
        ViewHolderC holderC = new ViewHolderC();
//        if(view==null){
//            switch (data.get(position)){
//                case "0":
//                    view = inflater.inflate(R.layout.home_fragment_floor_one,null);
//                    holderA.vp =(ImageView)view.findViewById(R.id.img);
////                    view.setTag(holderA);
////                    holderA.vp.setImageResource(R.mipmap.img_0016);
//                    break;
//                case "0":
//                    view = inflater.inflate(R.layout.home_fragment_floor_two,null);
//                    LinearLayout home_kepu = (LinearLayout) view.findViewById(R.id.home_kepu);
//                    home_kepu.setOnClickListener(new View.OnClickListener() {
//                        @Override
//                        public void onClick(View view) {
//                            Intent intent = new Intent();
//                            intent.setClass(context,KePuActivity.class);
//                            context.startActivity(intent);
//                        }
//                    });
////                    view.setTag(holderB);
////                    holderA.vp.setImageResource(R.mipmap.img_0018);
//                    break;
//                default:
                    view = inflater.inflate(R.layout.home_fragment_floor_three,null);
                    holderC.lv = (ListView) view.findViewById(R.id.home_fragment_floor_three_lv);
//                    holderC.lv.setAdapter();
//                    view.setTag(holderC);

                    HomeItemAdpter homeAdapterr =  new HomeItemAdpter(context,data);
                    holderC.lv.setAdapter(homeAdapterr);

//                    break;
//            }
//        }else {
//            switch (data.get(position)){
//                case "0":
//                    holderA= (ViewHolderA) view.getTag();
//                    holderA.vp.setImageResource(R.mipmap.img_0016);
//                    break;
//                case "1":
//                    holderB= (ViewHolderB) view.getTag();
//                    holderA.vp.setImageResource(R.mipmap.img_0018);
//                    break;
//                default:
//                    holderC= (ViewHolderC) view.getTag();
//                    break;
//            }
//        }
        return view;
    }

    class ViewHolderA{
        ImageView vp;
    }

    class ViewHolderB{//暂时数据写为固定的
        ImageView iv;
    }

    class ViewHolderC{
        ListView lv;
    }
}
